package spe.ui.editor.policy;

import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gef.editpolicies.ComponentEditPolicy;
import org.eclipse.gef.requests.GroupRequest;

import spe.model.spem.NodeElement;
import spe.ui.action.CancelableDeleteAction;
import spe.ui.action.PropertiesSelectionAction;
import spe.ui.editor.command.ElementDeleteCommand;
import spe.ui.editor.command.ShowPropertiesCommand;

public class ElementComponentEditPolicy extends ComponentEditPolicy 
{
	@Override
	protected Command createDeleteCommand(GroupRequest deleteRq)
	{
		NodeElement willBeDeletedNode = (NodeElement)getHost().getModel();
		ElementDeleteCommand cmd = new ElementDeleteCommand();
		System.out.println(String.format("[ElementComponentPolicy] Command: %s ", cmd));
		cmd.setElement(willBeDeletedNode);
		return cmd;
	}
	
	/*
	public Command getCommand(Request rq)
	{
		if(rq.getType().equals(PropertiesSelectionAction.REQ_TYPE))
		{
			return (new ShowPropertiesCommand());
		}
		if(rq.getType().equals(CancelableDeleteAction.REQ_TYPE))
		{
			System.out.println(String.format("[ElementComponentPolicy] Command: DANG O DAY "));
			return (new ElementDeleteCommand());
		}
		return super.getCommand(rq);
	}*/
}
